import { verifyTable } from "../verify/index.js";
import { addModuleDialog } from "../settings/module.js";
import { addResourceDialog } from "../settings/resource.js";

let apiType = [
  {
    label: "JSON模板",
    value: "JSON",
  },
  {
    label: "SQL模板",
    value: "SQL",
  },
];

let apiActionTypeOptions = [
  {
    label: "新增",
    value: "ADD",
  },
  {
    label: "删除",
    value: "DELETE",
  },
  {
    label: "编辑",
    value: "EDIT",
  },
  {
    label: "单条查询",
    value: "ROW",
  },
  {
    label: "单表查询",
    value: "LIST",
  },
  {
    label: "普通查询",
    value: "GET",
  },
  {
    label: "下拉栏查询",
    value: "SELECT",
  },
  {
    label: "目录树查询",
    value: "TREE",
  },
];

let selectFieldColumns = [
  {
    name: "label",
    label: "字段名称",
  },
  {
    name: "field_type",
    label: "字段类型",
  },
  {
    name: "field_desc",
    label: "字段描述",
  },
];

let systemId = {
  type: "select",
  name: "system_id",
  label: "系统名称",
  menuTpl: "<div>${label}-${sys_code}</div>",
  required: true,
  clearable: true,
  source: {
    method: "get",
    url: "/_dev/system/select",
  },
};

let moduleId = {
  type: "select",
  name: "module_id",
  label: "模块名称",
  menuTpl: "<div>${label}-${m_code}</div>",
  clearable: true,
  required: true,
  creatable: true,
  disabledOn: "${system_id == null}",
  addControls: [
    {
      type: "text",
      name: "label",
      required: true,
      label: "模块名称",
    },
    {
      type: "text",
      name: "value",
      required: true,
      label: "模块编号",
    },
  ],
  addApi: {
    method: "post",
    url: "/_dev/module/add",
    data: {
      m_code: "${value}",
      m_name: "${label}",
      system_id: "${system_id}",
    },
  },
  source: {
    method: "get",
    url: "/_dev/module/select?system_id=${system_id}",
    sendOn: "${system_id != null}",
  },
};

let resourceId = {
  type: "select",
  name: "resource_id",
  id: "resource_tree",
  label: "资源名称",
  menuTpl: "<div>${label}-${res_code}</div>",
  clearable: true,
  required: true,
  disabledOn: "${module_id == null}",
  source: {
    method: "get",
    url: "/_dev/resource/select?system_id=${system_id}&module_id=${module_id}",
    sendOn: "${system_id != null && module_id != null}",
  },
  addControls: [
    {
      type: "text",
      name: "label",
      required: true,
      label: "资源名称",
    },
    {
      type: "text",
      name: "value",
      required: true,
      label: "资源编号",
    },
  ],
  addApi: {
    method: "post",
    url: "/_dev/resource/add",
    data: {
      res_code: "${value}",
      res_name: "${label}",
      system_id: "${system_id}",
      module_id: "${module_id}",
    },
  },
};

let databaseId = {
  label: "数据库",
  type: "select",
  name: "database_id",
  required: true,
  source: {
    method: "get",
    url: "/_dev/database/select?system_id=${system_id}",
    sendOn: "${system_id != null}",
  },
};

let schemaName = {
  label: "库/用户",
  type: "select",
  name: "schema_name",
  clearable: true,
  disabledOn: "${database_id == null}",
  source: {
    method: "get",
    url: "/_dev/database/db/list?database_id=${database_id}",
    sendOn: "${database_id != null}",
  },
};

function setRequired(schemaName) {
  var tmpSchemaName = JSON.parse(JSON.stringify(schemaName));
  tmpSchemaName.required = true;

  return tmpSchemaName;
}

let tableName = {
  label: "表名称",
  type: "select",
  name: "table_name",
  clearable: true,
  searchable: true,
  disabledOn: "${schema_name == null}",
  source: {
    method: "get",
    url: "/_dev/database/table/list?database_id=${database_id}&db_name=${schema_name}",
    sendOn: "${database_id != null && schema_name != null}",
  },
  onEvent: {
    change: {
      actions: [
        {
          actionType: "setValue",
          componentId: "res_code",
          args: {
            value: "${event.data.selectedItems.value}",
          },
        },
        {
          actionType: "setValue",
          componentId: "res_name",
          args: {
            value: "${event.data.selectedItems.label}",
          },
        },
      ],
    },
  },
};

let idField = {
  label: "主键字段",
  type: "select",
  name: "id_field",
  value: "id",
  clearable: true,
  visibleOn: "${table_name != null && table_name != ''}",
  max: 64,
  selectMode: "table",
  columns: selectFieldColumns,

  source: {
    method: "get",
    url: "/_dev/database/field/list?database_id=${database_id}&db_name=${schema_name}&table_name=${table_name}",
    sendOn:
      "${database_id != null && schema_name != null && table_name != null}",
  },
};

let inputIdField = {
  type: "input-text",
  name: "id_field",
  label: "主键字段",
  clearable: true,
  visibleOn: "${table_name == null || table_name == ''}",
  value: "id",
};

let primaryFields = {
  type: "select",
  name: "primary_fields",
  label: "唯一字段",
  clearable: true,
  visibleOn: "${table_name != null && table_name != ''}",
  placeholder: "输入字段名按“ENTER”键确认,用于记录重复判断",
  multiple: true,
  selectMode: "table",
  columns: selectFieldColumns,
  source: {
    method: "get",
    url: "/_dev/database/field/list?database_id=${database_id}&db_name=${schema_name}&table_name=${table_name}",
    sendOn:
      "${database_id != null && schema_name != null && table_name != null}",
  },
};

let inputPrimaryFields = {
  type: "input-tag",
  name: "primary_fields",
  label: "唯一字段",
  enableBatchAdd: true,
  clearable: true,
  visibleOn: "${table_name == null || table_name == ''}",
  separator: ",",
  max: 256,
  placeholder: "输入字段名按“ENTER”键确认,用于记录重复判断",
};

let requiredFields = {
  type: "select",
  name: "required_fields",
  label: "必填字段",
  clearable: true,
  visibleOn: "${table_name != null && table_name != ''}",
  placeholder: "输入字段名按“ENTER”键确认,用于字段校验",
  multiple: true,
  selectMode: "table",
  columns: selectFieldColumns,
  source: {
    method: "get",
    url: "/_dev/database/field/list?database_id=${database_id}&db_name=${schema_name}&table_name=${table_name}",
    sendOn:
      "${database_id != null && schema_name != null && table_name != null}",
  },
};

let inputRequiredFields = {
  type: "input-tag",
  name: "required_fields",
  label: "必填字段",
  enableBatchAdd: true,
  clearable: true,
  visibleOn: "${table_name == null || table_name == ''}",
  separator: ",",
  max: 256,
  placeholder: "输入字段名按“ENTER”键确认,用于字段校验",
};

let likeFields = {
  type: "select",
  name: "like_fields",
  multiple: true,
  clearable: true,
  visibleOn: "${table_name != null && table_name != ''}",
  columns: selectFieldColumns,
  label: "模糊查询字段",
  max: 256,
  selectMode: "table",
  placeholder: "输入字段名按“ENTER”键确认,用于模糊查询",
  source: {
    method: "get",
    url: "/_dev/database/field/list?database_id=${database_id}&db_name=${schema_name}&table_name=${table_name}",
    sendOn:
      "${database_id != null && schema_name != null && table_name != null}",
  },
};

let inputLikeFields = {
  type: "input-tag",
  name: "like_fields",
  label: "模糊查询字段",
  enableBatchAdd: true,
  clearable: true,
  visibleOn: "${table_name == null || table_name == ''}",
  separator: ",",
  max: 256,
  placeholder: "输入字段名按“ENTER”键确认,用于模糊查询",
};

let apiActionType = {
  label: "操作类型",
  type: "select",
  name: "api_action_type",
  options: apiActionTypeOptions,
  required: true,
  onEvent: {
    change: {
      actions: [
        {
          actionType: "ajax",
          api: {
            method: "post",
            url: "/_dev/interface/create_template",
            data: {
              api_type: "JSON",
              api_action_type: "${api_action_type|default:undefined}",
              schema_name: "${schema_name|default:undefined}",
              table_name: "${table_name|default:undefined}",
              id_field: "${id_field|default:undefined}",
              primary_fields: "${primary_fields|default:undefined}",
              like_fields: "${like_fields|default:undefined}",
            },
          },
        },
        {
          actionType: "setValue",
          componentId: "api_template",
          args: {
            value:
              "${ENCODEJSON(event.data.responseResult.responseData.api_template)}",
          },
        },
        {
          actionType: "setValue",
          componentId: "api_path",
          args: {
            value: "${event.data.selectedItems.value | lowerCase}",
          },
        },
        {
          actionType: "setValue",
          componentId: "api_name",
          args: {
            value: "${event.data.selectedItems.label}",
          },
        },
        {
          actionType: "setValue",
          componentId: "api_desc",
          args: {
            value: "${event.data.selectedItems.label}",
          },
        },
      ],
    },
  },
};
let sqlApiActionType = {
  label: "操作类型",
  type: "select",
  name: "api_action_type",
  options: apiActionTypeOptions,
  required: true,
  onEvent: {
    change: {
      actions: [
        {
          actionType: "ajax",
          api: {
            method: "post",
            url: "/_dev/interface/create_template",
            data: {
              database_id: "${database_id}",
              api_type: "SQL",
              api_action_type: "${api_action_type|default:undefined}",
              schema_name: "${schema_name|default:undefined}",
              table_name: "${table_name|default:undefined}",
              id_field: "${id_field|default:undefined}",
              primary_fields: "${primary_fields|default:undefined}",
              like_fields: "${like_fields|default:undefined}",
            },
          },
        },
        {
          actionType: "setValue",
          componentId: "api_template",
          args: {
            value: "${event.data.responseResult.responseData.api_template}",
          },
        },
        {
          actionType: "setValue",
          componentId: "api_path",
          args: {
            value: "${event.data.selectedItems.value | lowerCase}",
          },
        },
        {
          actionType: "setValue",
          componentId: "api_name",
          args: {
            value: "${event.data.selectedItems.label}",
          },
        },
        {
          actionType: "setValue",
          componentId: "api_desc",
          args: {
            value: "${event.data.selectedItems.label}",
          },
        },
      ],
    },
  },
};

let apiPath = {
  label: "接口编号",
  type: "input-text",
  name: "api_path",
  id: "api_path",
  maxLength: 64,
  placeholder: "只能输入字母 数字 - _ 字符",
  showCounter: true,
  required: true,
  validations: {
    isUrlPath: true,
    minLength: 1,
    maxLength: 64,
  },
};
let apiName = {
  label: "接口名称",
  type: "input-text",
  name: "api_name",
  id: "api_name",
  maxLength: 64,
  showCounter: true,
  required: true,
};

let apiDesc = {
  label: "接口描述",
  type: "input-text",
  name: "api_desc",
  id: "api_desc",
  maxLength: 128,
  showCounter: true,
  required: true,
};

let jsonApiTemplate = {
  type: "editor",
  name: "api_template",
  id: "api_template",
  maxLength: 4000,
  showCounter: true,
  label: "JSON模板,兼容apijson语法",
  language: "json",
  size: "lg",
  trimContents: true,
  required: true,
  options: {
    lineNumbers: true,
  },
};

let sqlApiTemplate = {
  type: "editor",
  name: "api_template",
  id: "api_template",
  maxLength: 4000,
  showCounter: true,
  label: "SQL模板,兼容MyBaits模板语法",
  language: "sql",
  size: "xl",
  trimContents: true,
  required: true,
  options: {
    lineNumbers: true,
  },
};
let actions = [
  {
    label: "取消",
    type: "button",
    actionType: "close",
    level: "default",
  },
  {
    label: "确认",
    type: "button",
    actionType: "submit",
    level: "primary",
  },
];

function setObjDisable(obj) {
  var tmpObj = JSON.parse(JSON.stringify(obj));
  tmpObj.disabled = true;

  return tmpObj;
}

function setArrayDisable(objArray) {
  var tmpObjArray = new Array();
  for (var i = 0; i < objArray.length; i++) {
    var tmpObj = JSON.parse(JSON.stringify(objArray[i]));
    tmpObj.disabled = true;
    tmpObjArray.push(tmpObj);
  }

  return tmpObjArray;
}

let batchAddDialog = {
  label: "批量新增接口",
  type: "button",
  actionType: "dialog",
  level: "info",
  dialog: {
    title: "批量新增接口",
    size: "lg",
    body: {
      type: "form",
      reload: "system_tree",
      api: {
        method: "post",
        url: "/_dev/interface/batch_add",
        data: {
          "&": "$$",
        },
      },
      body: [
        {
          type: "radios",
          name: "api_type",
          label: "模板类型",
          required: true,
          value: "JSON",
          options: apiType,
        },
        {
          type: "group",
          body: [systemId, moduleId, resourceId],
        },
        {
          type: "group",
          body: [databaseId, setRequired(schemaName), setRequired(tableName)],
        },

        idField,
        primaryFields,
        requiredFields,
        likeFields,
      ],
    },
    actions: actions,
  },
};

let addJsonDialog = {
  label: "新增JSON模板接口",
  type: "button",
  level: "success",
  actionType: "dialog",
  dialog: {
    title: "新增JSON模板接口",
    size: "lg",
    body: {
      type: "form",
      api: {
        method: "post",
        url: "/_dev/interface/add",
        data: {
          "&": "$$",
          api_rel_table: "${table_name|default:undefined}",
          api_type: "JSON",
          api_status: 1,
        },
      },
      body: [
        {
          type: "group",
          body: [systemId, moduleId, resourceId],
        },
        {
          type: "group",
          body: [databaseId, schemaName, tableName],
        },
        {
          type: "group",
          body: [apiActionType, apiPath, apiName],
        },
        {
          type: "tabs",
          tabsMode: "card",
          swipeable: true,
          tabs: [
            {
              title: "JSON模板",
              body: jsonApiTemplate,
            },
            {
              title: "字段配置",
              body: [
                idField,
                primaryFields,
                requiredFields,
                likeFields,
                inputIdField,
                inputPrimaryFields,
                inputRequiredFields,
                inputLikeFields,
              ],
            },
          ],
        },
      ],
    },
    actions: actions,
  },
};

let editJsonDialog = {
  label: "编辑",
  type: "button",
  actionType: "dialog",
  visibleOn: "${api_type==='JSON'}",
  level: "primary",
  dialog: {
    title: "编辑JSON模板接口",
    size: "lg",
    body: {
      type: "form",
      mode: "horizontal",
      api: {
        method: "post",
        url: "/_dev/interface/edit",
        data: {
          id: "${id}",
          "&": "$$",
        },
      },
      body: [
        {
          type: "group",
          body: setArrayDisable([systemId, databaseId]),
        },
        {
          type: "group",
          body: setArrayDisable([
            {
              type: "select",
              name: "module_id",
              label: "模块名称",
              menuTpl: "<div>${label}-${m_code}</div>",
              clearable: true,
              required: true,
              source: {
                method: "get",
                url: "/_dev/module/select?system_id=${system_id}",
                sendOn: "${system_id != null}",
              },
            },
            {
              type: "select",
              name: "resource_id",
              id: "resource_tree",
              label: "资源名称",
              menuTpl: "<div>${label}-${res_code}</div>",
              clearable: true,
              required: true,
              source: {
                method: "get",
                url: "/_dev/resource/select?system_id=${system_id}&module_id=${module_id}",
                sendOn: "${system_id != null && module_id != null}",
              },
            },
          ]),
        },
        {
          type: "group",
          body: [setObjDisable(apiActionType), apiPath, apiName],
        },

        {
          type: "tabs",
          tabsMode: "card",
          swipeable: true,
          tabs: [
            {
              title: "JSON模板",
              body: jsonApiTemplate,
            },
            {
              title: "字段配置",
              body: [
                idField,
                primaryFields,
                requiredFields,
                likeFields,
                inputIdField,
                inputPrimaryFields,
                inputRequiredFields,
                inputLikeFields,
              ],
            },

            {
              title: "参数校验",
              body: verifyTable,
            },
            {
              title: "鉴权管理",
              body: "",
            },
          ],
        },
      ],
    },
    actions: actions,
  },
};

let formatSql = {
  label: "SQL格式化",
  type: "button",
  actionType: "ajax",
  level: "info",
  api: {
    method: "post",
    url: "/_dev/interface/format_sql",
    data: {
      api_template: "${api_template}",
    },
  },
};

let addSqlDialog = {
  label: "新增SQL模板接口",
  type: "button",
  level: "success",
  actionType: "dialog",
  dialog: {
    title: "新增SQL模板接口",
    size: "lg",
    body: {
      type: "form",
      data: {
        tableFields: [],
      },
      api: {
        method: "post",
        url: "/_dev/interface/add",
        data: {
          "&": "$$",
          api_type: "SQL",
          api_status: 1,
        },
      },
      body: [
        {
          type: "group",
          body: [systemId, moduleId, resourceId],
        },
        {
          type: "group",
          body: [databaseId, schemaName, tableName],
        },
        {
          type: "group",
          body: [sqlApiActionType, apiPath, apiName],
        },
        {
          type: "tabs",
          tabsMode: "card",
          swipeable: true,
          tabs: [
            {
              title: "SQL模板",
              body: sqlApiTemplate,
            },
            {
              title: "字段配置",
              body: [
                idField,
                primaryFields,
                requiredFields,
                likeFields,
                inputIdField,
                inputPrimaryFields,
                inputRequiredFields,
                inputLikeFields,
              ],
            },
          ],
        },
      ],
    },
    actions: [
      formatSql,
      {
        label: "取消",
        type: "button",
        actionType: "close",
        level: "default",
      },
      {
        label: "确认",
        type: "button",
        actionType: "submit",
        level: "primary",
      },
    ],
  },
};

let editSqlDialog = {
  label: "编辑",
  type: "button",
  actionType: "dialog",
  level: "primary",
  visibleOn: "${api_type==='SQL'}",
  dialog: {
    title: "编辑SQL模板接口",
    size: "lg",
    body: {
      type: "form",
      api: {
        method: "post",
        url: "/_dev/interface/edit",
        data: {
          id: "${id}",
          api_type: "SQL",
          "&": "$$",
        },
      },
      body: [
        {
          type: "group",
          body: setArrayDisable([systemId, databaseId]),
        },
        {
          type: "group",
          body: setArrayDisable([
            {
              type: "select",
              name: "module_id",
              label: "模块名称",
              menuTpl: "<div>${label}-${m_code}</div>",
              clearable: true,
              required: true,
              source: {
                method: "get",
                url: "/_dev/module/select?system_id=${system_id}",
                sendOn: "${system_id != null}",
              },
            },
            {
              type: "select",
              name: "resource_id",
              id: "resource_tree",
              label: "资源名称",
              menuTpl: "<div>${label}-${res_code}</div>",
              clearable: true,
              required: true,
              source: {
                method: "get",
                url: "/_dev/resource/select?system_id=${system_id}&module_id=${module_id}",
                sendOn: "${system_id != null && module_id != null}",
              },
            },
          ]),
        },
        {
          type: "group",
          body: [setObjDisable(sqlApiActionType), apiPath, apiName],
        },

        {
          type: "tabs",
          tabsMode: "card",
          swipeable: true,
          tabs: [
            {
              title: "SQL模板",
              body: sqlApiTemplate,
            },
            {
              title: "字段配置",
              body: [
                idField,
                primaryFields,
                requiredFields,
                likeFields,
                inputIdField,
                inputPrimaryFields,
                inputRequiredFields,
                inputLikeFields,
              ],
            },
            {
              title: "参数校验",
              body: verifyTable,
            },
            {
              title: "鉴权管理",
              body: "",
            },
          ],
        },
      ],
    },
    actions: [
      formatSql,
      {
        label: "取消",
        type: "button",
        actionType: "close",
        level: "default",
      },
      {
        label: "确认",
        type: "button",
        actionType: "submit",
        level: "primary",
      },
    ],
  },
};

let deleteButton = {
  label: "删除",
  type: "button",
  actionType: "ajax",
  level: "danger",
  visibleOn: "${api_status===0}",
  confirmText: "确认删除接口[${api_name}]?",
  api: {
    method: "post",
    url: "/_dev/interface/del",
    data: {
      id: "${id}",
    },
  },
};

let disableDialog = {
  label: "停用",
  type: "button",
  actionType: "ajax",
  level: "warning",
  visibleOn: "${api_status===1}",
  confirmText: "确认停用接口[${api_name}]？",
  api: {
    method: "post",
    url: "/_dev/interface/edit",
    data: {
      id: "${id}",
      api_status: "0",
    },
  },
};

let enableDialog = {
  label: "启用",
  type: "button",
  actionType: "ajax",
  level: "success",
  visibleOn: "${api_status===0}",
  confirmText: "确认启用接口[${api_name}]？",
  api: {
    method: "post",
    url: "/_dev/interface/edit",
    data: {
      id: "${id}",
      api_status: "1",
    },
  },
};

let filter = {
  title: "",
  body: [
    {
      type: "group",
      body: [
        {
          type: "hidden",
          name: "system_id",
        },
        {
          type: "hidden",
          name: "module_id",
        },
        {
          type: "hidden",
          name: "resource_id",
        },
        {
          type: "input-text",
          name: "api_path_name",
          clearable: true,
          placeholder: "URI",
          size: "sm",
        },
        {
          placeholder: "模板类型",
          type: "select",
          name: "api_type",
          clearable: true,
          size: "sm",
          options: apiType,
        },
        {
          placeholder: "操作类型",
          type: "select",
          name: "api_action_type",
          clearable: true,
          size: "sm",
          options: apiActionTypeOptions,
        },

        {
          placeholder: "状态",
          type: "select",
          name: "api_status",
          size: "sm",
          clearable: true,
          options: [
            {
              label: "停用",
              value: "0",
            },
            {
              label: "启用",
              value: "1",
            },
          ],
        },
        {
          type: "button-toolbar",
          buttons: [
            {
              type: "reset",
              label: "重置",
            },
            {
              type: "submit",
              level: "primary",
              label: "查询",
            },
          ],
        },
      ],
    },
  ],
  actions: [],
};

let interfaceCrud = {
  type: "crud",
  perPage: 10,
  name: "detail",
  id: "crud_reload",
  autoFillHeight: true,
  affixHeader: true,
  filter: filter,
  alwaysShowPagination: true,
  api: {
    method: "get",
    url: "/_dev/interface/list",
    data: {
      "&": "$$",
      system_id: "${system_id|default:undefined}",
      module_id: "${module_id|default:undefined}",
      resource_id: "${resource_id|default:undefined}",
      page: "${page|default:undefined}",
      perPage: "${perPage|default:undefined}",
      orderBy: "${orderBy|default:undefined}",
      orderDir: "${orderDir|default:undefined}",
    },
  },
  headerToolbar: [batchAddDialog, addJsonDialog, addSqlDialog],
  footerToolbar: [
    "statistics",
    {
      type: "pagination",
      layout: "perPage,pager",
    },
  ],

  syncLocation: false,
  filterTogglable: true,
  primaryField: "id",
  columns: [
    {
      name: "_index",
      label: "序号",
      width: 50,
    },
    {
      type: "service",
      name: "sys_module_name",
      label: "系统/模块/资源",
      body: {
        type: "tpl",
        tpl: "${sys_name}/${m_name}/${res_name}",
      },
      width: 300,
    },
    {
      name: "api_name",
      label: "接口名称",
      width: 200,
    },
    {
      type: "service",
      name: "api_addr",
      label: "URI",
      body: {
        type: "tpl",
        tpl: "/${sys_code}/${m_code}/${res_code}/${api_path}",
      },
    },
    {
      name: "api_type",
      label: "模板类型",
      width: 100,
    },
    {
      name: "api_action_type",
      label: "操作类型",
      width: 100,
    },
    {
      name: "update_time",
      label: "更新时间",
      width: 120,
    },

    {
      name: "api_status",
      label: "状态",
      type: "mapping",
      map: {
        0: "<span class='label label-default'>停用</span>",
        1: "<span class='label label-success'>启用</span>",
      },
      width: 50,
    },
    {
      type: "operation",
      label: "操作",
      buttons: [
        editJsonDialog,
        editSqlDialog,
        deleteButton,
        enableDialog,
        disableDialog,
      ],
      width: 200,
    },
  ],
};

let asideBody = {
  type: "form",
  wrapWithPanel: false,
  target: "window",
  submitOnInit: true,
  body: [
    {
      type: "input-tree",
      name: "cut",
      id: "system_tree",
      inputClassName: "no-border no-padder ",
      heightAuto: true,
      inputOnly: true,
      showOutline: true,
      itemHeight: 50,
      searchable: true,
      searchConfig: {
        sticky: true,
        clearable: true,
      },
      initiallyOpen: false,
      unfoldedLevel: 1,
      menuTpl: "</div><span>${label}(${children_count})</span></div>",
      source: {
        method: "get",
        url: "/_dev/system/tree",
      },
      onEvent: {
        change: {
          actions: [
            {
              componentId: "crud_reload",
              actionType: "reload",
              data: {
                system_id: "${event.data.item.system_id}",
                module_id: "${event.data.item.module_id}",
                resource_id: "${event.data.item.resource_id}",
              },
            },
          ],
        },
      },
    },
  ],
};
let interfacePage = {
  type: "page",
  asideClassName: "bg-gray-100 py-1.5 w-80",
  bodyClassName: "bg-gray-100",
  aside: asideBody,
  body: [interfaceCrud],
};

export { interfacePage };
